Repetier-Firmware  1.0.0
Events.h
Go to the documentation of this file.
1 #ifndef EVENTS_H_INCLUDED
2 #define EVENTS_H_INCLUDED
3 
4 /*
5 Event system in a nutshell:
6 
7 All printers are different and my need additions in the one or other place.
8 It is not very convenient to add these code parts across the firmware. For this
9 reason repetier-firmware uses a simple event system that comes at no cost if
10 a event is not used.
11 
12 - simple: Only one subscriber is possible
13 - cost effective: Macros work as event caller. By default all macros are empty
14 
15 How to use the system:
16 
17 1. In Configuration.h add
18 #define CUSTOM_EVENTS
19 2. Add a file "CustomEvents.h" which overrides all event macros you need.
20  It should also include the function declarations used.
21 3. Add a file "CustomEventsImpl.h" which includes all function definitions.
22  Also it is named .h it will be included inside a cpp file only once.
23  This is to compile only when selected and still keep ArduinoIDE happy.
24 
25 Each of the following events describe the parameter and when it is called.
26 */
27 
28 // Catch heating events. id is extruder id or -1 for heated bed.
29 #define EVENT_WAITING_HEATER(id) {}
30 #define EVENT_HEATING_FINISHED(id) {}
31 
32 // This gets called every 0.1 second
33 #define EVENT_TIMER_100MS {}
34 // This gets called every 0.5 second
35 #define EVENT_TIMER_500MS {}
36 // Gets called on a regular basis as time allows
37 #define EVENT_PERIODICAL {}
38 // Gets called when kill gets called. only_steppes = true -> we only want to disable steppers, not everything.
39 #define EVENT_KILL(only_steppers) {}
40 // Gets called when a jam was detected.
41 #define EVENT_JAM_DETECTED {}
42 // Gets called every time the jam detection signal switches. Steps are the extruder steps since last change.
43 #define EVENT_JAM_SIGNAL_CHANGED(extruderId,steps) {}
44 // Gets called if a heater decoupling is detected.
45 #define EVENT_HEATER_DECOUPLED(id) {}
46 // Gets called if a missing/shorted thermistor is detected.
47 #define EVENT_HEATER_DEFECT(id) {}
48 // Gets called if a action in ui.cpp okAction gets executed.
49 #define EVENT_START_UI_ACTION(shortAction) {}
50 // Gets called if a nextPrevius actions gets executed.
51 #define EVENT_START_NEXTPREVIOUS(action,increment) {}
52 // Gets called before a move is queued. Gives the ability to limit moves.
53 #define EVENT_CONTRAIN_DESTINATION_COORDINATES
54 // Gets called when a fatal error occurs and all actions should be stopped
55 #define EVENT_FATAL_ERROR_OCCURED
56 // Gets called after a M999 to continue from fatal errors
57 #define EVENT_CONTINUE_FROM_FATAL_ERROR
58 
59 // Called to initialize laser pins. Return false to prevent default initialization.
60 #define EVENT_INITIALIZE_LASER true
61 // Set laser to intensity level 0 = off, 255 = full. Return false if you have overridden the setting routine.
62 // with true the default solution will set it as digital value.
63 #define EVENT_SET_LASER(intensity) true
64 
65 // Called to initialize CNC pins. Return false to prevent default initialization.
66 #define EVENT_INITIALIZE_CNC true
67 // Turn off spindle
68 #define EVENT_SPINDLE_OFF true
69 // Turn spindle clockwise
70 #define EVENT_SPINDLE_CW(rpm) true
71 // Turn spindle counter clockwise
72 #define EVENT_SPINDLE_CCW(rpm) true
73 
74 // Allow adding new G and M codes. To implement it create a function
75 // bool eventUnhandledGCode(GCode *com)
76 // that returns true if it handled the code, otherwise false.
77 // Event define would then be
78 // #define EVENT_UNHANDLED_G_CODE(c) eventUnhandledGCode(c)
79 #define EVENT_UNHANDLED_G_CODE(c) false
80 #define EVENT_UNHANDLED_M_CODE(c) false
81 
82 // Called when bed temperature is set
83 #define EVENT_SET_BED_TEMP(temp,boop)
84 
85 // This gets called every time the user has saved a value to eeprom
86 // or any other reason why dependent values may need recomputation.
87 #define EVENT_UPDATE_DERIVED {}
88 
89 // Gets called after HAL is initialized, but before the regular pin settings is defined.
90 #define EVENT_INITIALIZE_EARLY {}
91 // This gets called after the basic firmware functions have initialized.
92 // Use this to initialize your hardware etc.
93 #define EVENT_INITIALIZE {}
94 
95 // Allows adding custom symbols in strings that get parsed. Return false if not replaced so defaults can trigger.
96 // override function signature: bool parser(uint8_t c1,uint8_t c2)
97 #define EVENT_CUSTOM_TEXT_PARSER(c1,c2) false
98 
99 // User interface actions
100 // These get only executed if there was no hot, so they are ideal to add new actions
101 
102 // ok button in wizard page is called
103 #define EVENT_UI_OK_WIZARD(action) {}
104 #define EVENT_UI_FINISH_ACTION(action) false
105 #define EVENT_UI_EXECUTE(action,allowMoves) {}
106 // Returns false if no function was executed
107 #define EVENT_UI_OVERRIDE_EXECUTE(action,allowMoves) false
108 #define EVENT_UI_NEXTPREVIOUS(action,allowMoves,increment) {}
109 // replace by function call returning true if it handled refresh page it self.
110 #define EVENT_UI_REFRESH_PAGE false
111 
112 // the following 2 events are equivalent to slow and fast key function and allow adding extra keys in event system.
113 // make sure action is called by reference so it can be changed and returned.
114 // Set action only if key is hit
115 #define EVENT_CHECK_FAST_KEYS(action) {}
116 #define EVENT_CHECK_SLOW_KEYS(action) {}
117 
118 // Events on sd pause
119 #define EVENT_SD_PAUSE_START(intern) true
120 #define EVENT_SD_PAUSE_END(intern) {}
121 #define EVENT_SD_CONTINUE_START(intern) true
122 #define EVENT_SD_CONTINUE_END(intern) {}
123 #define EVENT_SD_STOP_START true
124 #define EVENT_SD_STOP_END {}
125 
126 #define EVENT_BEFORE_Z_HOME {}
127 
128 #endif // EVENTS_H_INCLUDED